package com.bac.rentmap.ad.flat.rating.item;

import java.util.logging.Logger;

import com.bac.rentmap.ad.flat.FlatAd;

public class PublisherRatingItemCalculator implements RatingItemCalculator {
    private static final Logger log = Logger
            .getLogger(PublisherRatingItemCalculator.class.getName());

    private static final int AGENT_RATING = -150;
    private static final int EXTERNAL_RATING = -160;
    private static final int NOT_AGENT_RATING = 0;

    /**
    * Agent has bad rating. Agent rating = 1.5 day old rating.
    *
    * @param flatAd
    * @return
    */
    public long calculate(FlatAd flatAd) {
        long res;
        if(flatAd.getExternal()){
            res = EXTERNAL_RATING;
        }
        else if (flatAd.getAgent()) {
            res = AGENT_RATING;
        }
        else{
            res = NOT_AGENT_RATING;
        }
        log.fine("Publisher rating: " + res);
        return res;
    }

    public long getMaxPossibleRating() {
        return NOT_AGENT_RATING;
    }

    public long getMinPossibleRating() {
        return AGENT_RATING;
    }

}
